﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

using System.Security.Cryptography;//////////////////////////////////////
using System.Security.Cryptography.X509Certificates;



using System.Runtime.InteropServices;

namespace DES
{


    public partial class Form1 : Form
    {

        [DllImport("DES.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl)]
        public unsafe static extern void PlayDes(byte[] MesOut, byte[] MesIn);

        [DllImport("DES.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl)]
        public unsafe static extern void SetKey(byte[] KeyIn);


        public Form1()
        {
            InitializeComponent();
            byte[] pwd = new byte[8];
            pwd[0] = pwd[1] = pwd[2] = pwd[3] = pwd[4] = pwd[5] = pwd[6] = pwd[7] = 0xFF;
            SetKey(pwd);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            byte[] IN = new byte[8];
            byte[] OUT =new byte[8];
            IN[0] = IN[1] = IN[2] = IN[3] = IN[4] = IN[5] = IN[6] = IN[7] =0X11;
            unsafe
            {
                PlayDes(OUT,IN);
            }

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
